package com.xbongbong.paas.model.impl;

import com.xbongbong.paas.domain.dao.StageWorkflowDao;
import com.xbongbong.paas.domain.entity.StageWorkflowEntity;
import com.xbongbong.paas.model.StageWorkflowModel;
import com.xbongbong.paas.toolbox.exception.XbbException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 *  阶段工作流
 * @author 李少杰
 * @date 2021/11/17 19:56
 * @version v1.0.0
 */
@Service("stageWorkflowModel")
public class StageWorkflowModelImpl implements StageWorkflowModel {

    @Resource
    private StageWorkflowDao stageWorkflowDao;


    @Override
    public Integer insert(StageWorkflowEntity entity) throws XbbException {
        return stageWorkflowDao.insert(entity);
    }

    @Override
    public Integer update(StageWorkflowEntity entity) throws XbbException {
        return stageWorkflowDao.update(entity);
    }

    @Override
    public List<StageWorkflowEntity> findEntitys(Map<String, Object> param) {
        return stageWorkflowDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return stageWorkflowDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return stageWorkflowDao.findEntitys(param);
    }

    @Override
    public StageWorkflowEntity getByKey(Long key, String corpid) {
        return stageWorkflowDao.getByKey(key, corpid);
    }

    @Override
    public Integer save(StageWorkflowEntity stageWorkflowEntity) throws XbbException {
        if (Objects.isNull(stageWorkflowEntity.getId())) {
            return insert(stageWorkflowEntity);
        }
        return update(stageWorkflowEntity);
    }

    @Override
    public Integer delete(StageWorkflowEntity entity) {
        return stageWorkflowDao.deleteByKey(entity.getId(), entity.getCorpid());
    }

    @Override
    public void insertBatch(List<StageWorkflowEntity> list) {
        stageWorkflowDao.insertBatch(list);
    }

    @Override
    public void updateBatch(List<StageWorkflowEntity> stageWorkflowEntityList, String corpid) {
        stageWorkflowDao.updateBatch(stageWorkflowEntityList, corpid);
    }

    @Override
    public Integer deleteBatch(List<StageWorkflowEntity> stageWorkflowEntityList, String corpid) {
        return stageWorkflowDao.deleteBatch(stageWorkflowEntityList, corpid);
    }
}
